﻿namespace Specifications.Extensions
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq.Expressions;
    using System.Reflection;

    public class SinglePropertyAssertion<T, K> : PropertyAssertion<T>
        where T : class, INotifyPropertyChanged
    {
        private readonly Expression<Func<K>> _property;

        public SinglePropertyAssertion(INotifyPropertyChanged propertyOwner, Expression<Func<K>> property)
            : base(propertyOwner)
        {
            _property = property;
        }

        protected override IEnumerable<PropertyInfo> GetCandidateProperties()
        {
            return new[] {_property.GetPropertyInfo()};
        }

        public void RaisesChangeNotification()
        {
            base.Execute();
        }
    }
}